<template>
	<view>
		<view class="edgeInsetTop"></view>
		<view class="cu-form-group">
			<view class="title">姓名</view>
			<input type="text" placeholder="请填写长辈姓名" v-model="addressData.realname"></input>
			
		</view>
		<view class="cu-form-group">
			<view class="title">生日</view>
			<picker mode="date" :value="addressData.birthday || '选择长辈出生日期'" @change="DateChange">
				<view style="display: none;">
					<input name="birthday" :value="addressData.birthday" disabled></input>
				</view>
				<view class="picker">
					{{addressData.birthday || '选择长辈出生日期'}}
				</view>
			</picker>
		</view>

		<!-- 1.0.5升级 -->
		<!-- 1.0.6升级 -->
		<view class="padding-bj flex flex-direction margin-top">
			<button @tap="confirm" class="cu-btn wanl-bg-orange lg">保存</button>
		</view>
		<wanl-address ref='wanlAddress' @selectAddress="successSelectAddress"></wanl-address>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addressData: {
					realname: '',
					birthday: '',
				},
			}
		},
		onLoad(option) {
			let title = '新增生日提醒';
			if (option.type === 'newadd') {
				this.addressData.default = 1
			}
			if (option.type === 'edit') {
				title = '编辑生日提醒'
				this.addressData = JSON.parse(option.data)

			}
			this.manageType = option.type;
			this.$wanlshop.title(title);
		},
		onNavigationBarButtonTap() {
			this.confirm()
		},
		methods: {
			DateChange(e) {
				this.addressData.birthday = e.detail.value
			},
			//提交
			confirm() {
				let data = this.addressData;
				// alert(JSON.stringify(data))
				if (!data.realname) {
					this.$wanlshop.msg('请填写姓名');
					return;
				}

				this.$wanlshop.prePage().refreshList(data, this.manageType);
				this.$wanlshop.msg(`地址${this.manageType=='edit' ? '修改': '添加'}成功`);
				this.$wanlshop.back(1);
			}
		}
	}
</script>

<style>
	.cu-form-group {
		padding: 0 25rpx;
	}

	/* 1.1.5升级 */
	.cu-form-group.area {
		position: relative;
	}

	.cu-form-group.area .click {
		position: absolute;
		z-index: 99;
		right: 0;
		left: 0;
		top: 0;
		bottom: 0;
	}

	.cu-form-group .title {
		min-width: calc(4em + 15px);
		font-size: 26rpx;
	}

	.cu-form-group input,
	.cu-form-group textarea {
		font-size: 26rpx;
	}

	.cu-btn.lg {
		font-size: 32rpx;
		height: 86rpx;
	}

	.tipsScroll {
		width: 100%;
		height: 500rpx;
		padding: 0 50rpx;
	}

	.tipsScroll .item {
		margin: 25rpx 0;
	}

	.tipsScroll .item view {
		color: #B8B8B8;
		font-size: 22rpx;
	}

	.tipsScroll .item text {
		color: #333;
	}
</style>